package org.zjt.immutable;

import lombok.extern.slf4j.Slf4j;

/**
 * Description:
 *
 * @author juntao.zhang
 * Date: 2018-06-05 下午5:09
 * @see
 */
@Slf4j
public enum  Operation {


    PLUS("+"){
        @Override
        public double apply(double x, double y) {
            return x + y;
        }
    },MINUS("-"){
        @Override
        public double apply(double x, double y) {
            return x - y;
        }
    },DIVIDE("/"){
        @Override
        public double apply(double x, double y) {
            return x / y;
        }
    },MULT("*"){
        @Override
        public double apply(double x, double y) {
            return x * y;
        }
    };

    private final String name;

    Operation(String name) {
        this.name = name;
    }


    /**
     * 枚举类抽象出来的操作
     * @param x
     * @param y
     * @return
     */
    public abstract double apply(double x ,double y) ;


    public static void main(String[] args) {
        double apply = Operation.MULT.apply(3.2, 3.4);
        log.info("apply:{}",apply);
    }
}
